<?php


namespace App\Models;


use App\Traits\Model\Log;
use Illuminate\Database\Eloquent\Model;

class EntryorderLog extends Model
{
    use Log;

    protected $fillable = [
        'ip', 'remark'
    ];

    protected static function boot()
    {
        parent::boot();
        static::registerModelEvent('creating', function (EntryorderLog $model){
            $user = auth()->user();
            $model->setAttribute('ip', request()->getClientIp());
            $model->setAttribute('foreign', $user ? get_class($user) : null);
            $model->setAttribute('foreign_key', $user ? $user->getKey() : null);
        });
    }
}
